package bean;

import java.util.Objects;

/**
 * @Auther leiHua
 * @Date 2022/5/8
 * 成绩信息类
 */
public class Score {
    private static final long serialVersionUID=1L;
    private Athlete athlete;   //运动员类
    private Competition competition; // 比赛项目类
    private String grade ;  //成绩
    private int    rank;    //排名

    public Score(Athlete athlete, Competition competition, String grade, int rank) {
        this.athlete = athlete;
        this.competition = competition;
        this.grade = grade;
        this.rank = rank;
    }

    public Athlete getAthlete() {
        return athlete;
    }

    public void setAthlete(Athlete athlete) {
        this.athlete = athlete;
    }

    public Competition getCompetition() {
        return competition;
    }

    public void setCompetition(Competition competition) {
        this.competition = competition;
    }

    public String getGrade() {
        return grade;
    }

    public void setGrade(String grade) {
        this.grade = grade;
    }

    public int getRank() {
        return rank;
    }

    public void setRank(int rank) {
        this.rank = rank;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Score score = (Score) o;
        return rank == score.rank && Objects.equals(athlete, score.athlete) && Objects.equals(competition, score.competition) && Objects.equals(grade, score.grade);
    }

    @Override
    public int hashCode() {
        return Objects.hash(athlete, competition, grade, rank);
    }

    @Override
    public String toString() {
        return "Score{" +
                "athlete=" + athlete +
                ", competition=" + competition +
                ", grade='" + grade + '\'' +
                ", rank=" + rank +
                '}';
    }
}
